/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.business.calcs;

import TimeRecording.enums.PartOfDay;

/**
 *
 * @author david
 */
public class HolidayAllocation {

    private PartOfDay partOfDay;
    private double spend;
    private double adjustment;

    //==========================================================================

    public PartOfDay getPartOfDay() {
        return partOfDay;
    }

    public void setPartOfDay(PartOfDay partOfDay) {
        this.partOfDay = partOfDay;
    }

    public void adjustPartOfDay(PartOfDay partOfDay) {

        // If we're adjusting by "nothing" then just bail out
        if (partOfDay == null) {
            return;
        }

        // If we currently have nothing then just take whatever we're given
        if (this.partOfDay == null) {
            this.partOfDay = partOfDay;
            return;
        }

        // If we're adjusting by a full day then it trumps anything else
        if (partOfDay == PartOfDay.ALL_DAY) {
            this.partOfDay = partOfDay;
        }

        // If we've got a full day (either already or just set) then bail out
        if (this.partOfDay == PartOfDay.ALL_DAY) {
            return;
        }

        // We must have 2 half days; if different then we've full day
        if (partOfDay != this.partOfDay) {
            this.partOfDay = partOfDay;
        }
    }

    public double getSpend() {
        return spend;
    }

    public void setSpend(double spend) {
        this.spend = spend;
    }

    public void adjustSpend(double spend) {
        this.spend += spend;
    }

    public double getAdjustment() {
        return adjustment;
    }

    public void setAdjustment(double adjustment) {
        this.adjustment = adjustment;
    }

    public void adjustAdjustment(double adjustment) {
        this.adjustment += adjustment;
    }

    //==========================================================================

    @Override
    public String toString() {
        return "partOfDay=" + partOfDay + ", " +
                "spend=" + spend + ", " +
                "adjustment=" + adjustment;
    }
}
